{% extends "homepage.html" %}

{% block content %}

<script type="text/javascript" src="{{url_for('emf.static', filename='elliptic_modular_form_util-functions.js') }}"></script>
<script type="text/javascript" src="{{ url_for('emf.static', filename='elliptic_modular_form_scripts.js') }}"></script>



{% if info.error is defined %}

<h1>There was an error in meeting your previous request. Please change parameters.</h1>

<div> 
<h2> Error message: </h2>
{{ info.error | safe }}
</div>
{% endif %}
{# To make an interface that is easier to read we implement each case of input separately #}

{# {{ info | safe }} $("div").data("option",{"start":1}); #}

<script>
$(document).ready(function() {
$("#l_list").data("start",1); $("#l_list").data("len",20); $("#l_list").data("min",1);
$("#l_list").data("name","level");
$("#w_list").data("start",1); $("#w_list").data("len",20); $("#w_list").data("min",1);
$("#w_list").data("name","weight");
$("#char_selection").data("char",0);
 print_list("#l_list");
 print_list("#w_list");
 });

function shift(id,lr) {
   var start = $(id).data("start");
   var min = $(id).data("min");
   var len = $(id).data("len");
   if (lr == "left")
      start = start - len;
   if (lr == "right")
      start = start + len;
   if (start <= min) {
      start = min;
   }
   $(id).contents().detach();
   $(id).data("start",start);
   $(id).data("min",min);
   $(id).data("len",len);
 /*alert("start:"+$(id).data("start")+" "+len+" "+min); */
   print_list(id);

}

function print_list(id) {
    var min = $(id).data("min");
    var start = $(id).data("start");
    var len = $(id).data("len");
    var name = $(id).data("name");
    var url = getAbsolutePath();
    if (start > min) {
       $(id).append("<a id='go_left' href='#' onclick=\"shift('"+id+"','left')\" style=\"\"><small>&lt;&lt;</small></a>");
    };
    var char = $("#char_selection").data("char");
    if (char == 0) {
       s = "&character=0"
    } else {
       s = "&character=all"
    }
    for (var i = start; i < len+start; i++) {
        /*s = "<a href="+url+"?"+name+"="+i+" style=\"display:inline\">" + i + "</a> ";*/
  /*s = "<a href='' onclick='set_value(\""+id+"\","+i+");document.browse.submit()' >" + i + "</a> ";*/
        s = "<a href=\"javascript:set_value('"+id+"',"+i+")\" style=\"display:inline\">" + i + "</a> ";
	$(id).append(s);
    }
    $(id).append("<a id='go_right' href='#' onclick=\"shift('"+id+"','right')\" style=\"display:inline\"><small>&gt;&gt;</small></a>");

};

function set_value(id,val) {
  var name = $(id).data("name"); 			   
  document.forms.browse[name].value=val;
  $(id).data("value",val);
  document.browse.submit();			   
}
</script>
{% if info.grouptype == 0 %}
    {% set group=KNOWL('mf.sl2.subgroup.gamma0n',title='\(\Gamma_0(N)\)') %}
    {% set chi = 0%}
{% elif info.grouptype == 1 %}
    {% set group=KNOWL('mf.sl2.subgroup.gamma1n',title='\(\Gamma_1(N)\)') %}
    {% set chi = -1%}
{% endif %}

{%if info.show_switch is defined %}
  {% if info.groupother == 1 %}
  {% set groupotherchar = -1 %}
  {% else %}
  {% set groupotherchar = 0 %}
  {%endif%}
  <div style="float:right;margin-right:30px;"><h2 style="font-size:1.2em"><a href="{{url_for('.render_elliptic_modular_forms',character=groupotherchar)}}">Switch to \(\Gamma_{{info.groupother}}(N)\)</a></h2></div>
{%endif%}

<h1>Browse holomorphic {{KNOWL('mf.elliptic.newform',title='newforms')}} for {{group}}</h1>

<div>
      {% if info.browse_table.rows is defined %}
      {#{KNOWLl('mf.elliptic.browse.all.info') } #}
The table below gives the dimensions of the space of holomorphic 
{{KNOWL('mf.elliptic.new_form',title='newforms')}} of integral
{{KNOWL('mf.elliptic.weight',title='weight')}} for {{group}}
{% if info.grouptype == 1 %}
.
{% else %}
, with trivial {{KNOWL('character.dirichlet', title='character')}}.
{% endif %}
</div>

<style>
table.ntdata th.left {
  border-right: 2px solid #9b9;
  background: #efe;
  border-bottom: 0;
  text-align: right;
}
table.ntdata td { text-align: left; }
table.ntdata th.weight {
  text-align: left;
  background: #efe;
  border-bottom: 2px solid #9b9;
  border-left: 0;
  vertical-align: center;
}
table.ntdata thead tr.space {
  background: #efe;
  border-bottom: 0;
}

table.ntdata thead th.spaceleft {
  border-right: 2px solid #9b9;
  vertical-align: top;
}

</style>
      {% set table = info.browse_table %}
      {% set rows = info.browse_table.rows %}
      <table class="ntdata">
        <thead>
          <tr class="space">
           <th class="spaceleft">Weight</th>
           <th class="weight" colspan="{{table.col_heads|length}}">
	     <span style="display:block;float:left;margin-right:3px;">Level \(N\)</span>
	   </th>
          </tr>
          <tr class="space">
            <th class="spaceleft"></th>
            {% for N in table.col_heads  %}
	    {% set col_url = url_for('emf.render_elliptic_modular_forms',level=N,character=chi) %}
            <th class="level"><a href="{{col_url}}">{{N}}</a></th>
            {% endfor %}
          </tr>
        </thead>
        <tbody>
          {% for row in rows  %}
          <tr>
            <th class="left">
              {% set k = table.row_heads[loop.index-1] %}
              {% set row_url = url_for('emf.render_elliptic_modular_forms',weight=k,character=chi) %}
              <a href="{{ row_url }}">{{ k }}</a>
            </th>
            {% for cell in row  %}
            <td align="center">
	      {% if cell.url != '' %}
                <a href="{{cell.url}}">{{cell.dim}}</a>
              {% else %}
		{{cell.dim}}
	      {% endif  %}
            </td>
            {% endfor %}
          </tr>
          {% endfor %}
        </tbody>
      </table>
      {% endif %}
    </td>

{% include 'select_ranges.html' %}

  <h1>Find a specific cusp form from the database</h1>
      <div>
        Search by {{KNOWL('mf.elliptic.label',title="label")}} 
        <form name="search" method = "post" action="{{url_for('.render_elliptic_modular_forms')}}">	  
          <input type="text" name="jump_to" value="" placeholder="1.12"> 
	  <button type="submit" value="Find">Find</button>
        </form>
      </div>

{#
<h1>Search</h1>
<form name="search" method = "post" action="{{url_for('.render_elliptic_modular_forms')}}">
  <table class="">
    <tr>
      <td>
        {{KNOWL('mf.elliptic.level',title='Level')}}:
      </td><td><input type="text" name="level" value="" example="4"></td>
    </tr>
    <tr>
      <td>
        {{KNOWL('mf.elliptic.weight',title='Weight')}}:
      </td><td><input type="text" name="weight" value="" placeholder="12"></td>
    </tr>
    <tr>
      <td>
        {{KNOWL('mf.elliptic.character',title='Character')}}:
      </td><td><input type="text" name="character" value="" placeholder="0"></td> 
    </tr>
  </table>
  <button type="submit" name="Submit" value="Search">Search</button>
</form>
#}
{% endblock content %}
